#!/bin/bash

set -e

set -o pipefail

for pkg in fly; do
  pushd packages/$pkg
    {
      cat spec | grep -v '# gosub'
      gosub list -a github.com/concourse/$pkg | \
        sed -e 's/\(.*\)/  - \1\/*.go # gosub/g'
    } > spec.new

    mv spec.new spec
  popd
done

for pkg in atc blackbox baggageclaim tsa; do
  pushd packages/$pkg
    {
      cat spec | grep -v '# gosub'
      gosub list -a github.com/concourse/$pkg/cmd/... | \
        sed -e 's/\(.*\)/  - \1\/*.go # gosub/g'
    } > spec.new

    mv spec.new spec
  popd
done
